namespace LanSunERP
{
    using System;
    using System.ServiceModel;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Runtime.Serialization;
    using System.Collections;
    using System.Data;
    using System.Data.SqlClient;

    public class GUIDesignTime : QueryCommand
    {
        public GUIDesignTime() : base() { }
        public GUIDesignTime(SqlCommand cmdSQL, DataTable dtRequest, string RequestJob)
            : base(cmdSQL, dtRequest, RequestJob) { }
        public SqlCommand BuildCommand()
        {

            switch (RequestJob.Substring(6,4))
            {
                case "0000": 
                /*
                     case "GUIDesignTime":
                        GUIDesignTime m_GUIDesignTime = new GUIDesignTime(cmdSQL, dtRequest, RequestJob);
                        cmdSQL = m_GUIDesignTime.BuildCommand();
                        break;
                */
                    break;
                case "1000": 
                    break;
                 case "2001":
                 case "4000":
                    cmdSQL.Parameters.Add(new SqlParameter("@InstanceID", dwRequest["InstanceID"].ToString()));
                    break; 
                case "1369":  //IX_GoodsTypeKeyDef
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@KeyDefType", dwRequest["KeyDefType"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKey", dwRequest["GoodsTypeKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKeyDefKey", dwRequest["GoodsTypeKeyDefKey"].ToString()));  
                    break;
                case "1365":  //IX_GUIDesignTime
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@KeyDefType", dwRequest["KeyDefType"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKey", dwRequest["GoodsTypeKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKeyDefKey", dwRequest["GoodsTypeKeyDefKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsKey", dwRequest["GoodsKey"].ToString()));  
                    break;
                case "1368":  //IX_GUIDesignTime_GoodsTypeKeyDefKey
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKey", dwRequest["GoodsTypeKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKeyDefKey", dwRequest["GoodsTypeKeyDefKey"].ToString()));  
                    break;
                case "1367":  //IX_GUIDesignTime_Key
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@KeyDefType", dwRequest["KeyDefType"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKey", dwRequest["GoodsTypeKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKeyDefKey", dwRequest["GoodsTypeKeyDefKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsKey", dwRequest["GoodsKey"].ToString()));  
                    break;
                case "1370":  //IX_GUIDesignTime_MasterKey
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@KeyDefType", dwRequest["KeyDefType"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKey", dwRequest["GoodsTypeKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKeyDefKey", dwRequest["GoodsTypeKeyDefKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsKey", dwRequest["GoodsKey"].ToString()));  
                    break;
                case "1366":  //IX_GUIDesignTime_Parent
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@KeyDefType", dwRequest["KeyDefType"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKey", dwRequest["GoodsTypeKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKeyDefKey", dwRequest["GoodsTypeKeyDefKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsKey", dwRequest["GoodsKey"].ToString()));  
                    break;
                case "1372":  //IX_GUIDesignTime_SysID
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                    break;
                case "1537":  //IX_GUIDesignTime_TableID
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@ProfileID", dwRequest["ProfileID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@TableID", dwRequest["TableID"].ToString()));  
                    break;
                case "1373":  //IX_GUIDesignTime_UGoodsKey
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@KeyDefType", dwRequest["KeyDefType"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKey", dwRequest["GoodsTypeKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKeyDefKey", dwRequest["GoodsTypeKeyDefKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@UGoodsKey", dwRequest["UGoodsKey"].ToString()));  
                    break;
                case "1374":  //TX_GUIDesignTime
                  cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@KeyDefType", dwRequest["KeyDefType"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKey", dwRequest["GoodsTypeKey"].ToString()));  
                  cmdSQL.Parameters.Add(new SqlParameter("@GoodsTypeKeyDefKey", dwRequest["GoodsTypeKeyDefKey"].ToString()));  
                    break;
               case "2000": 
               case "3001":
               case "3000":
                    cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@ProfileKey", dwRequest["ProfileKey"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@ProfileID", dwRequest["ProfileID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@TableName", dwRequest["TableName"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Column_Name", dwRequest["Column_Name"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@TableID", dwRequest["TableID"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@XPosition", dwRequest["XPosition"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@YPosition", dwRequest["YPosition"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Height", dwRequest["Height"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Width", dwRequest["Width"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@EditMode", dwRequest["EditMode"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Lang_Code", dwRequest["Lang_Code"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Column_Map_Name", dwRequest["Column_Map_Name"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@SubStatus", dwRequest["SubStatus"].ToString()));
                    cmdSQL.Parameters.Add(new SqlParameter("@Status", dwRequest["Status"].ToString()));
                    break;
            }
            return cmdSQL;

        }
        public override SqlCommand BuildInstanceKey(SqlCommand cmdSQL, DataRow dwTemp)
        {
            
                string InstanceKey = dwTemp["InstanceKey"].ToString().Trim();
                    string SysID=dwTemp["SysID"].ToString().Trim();
                    string KeyDefType=dwTemp["KeyDefType"].ToString().Trim();
                    string GoodsTypeKey=dwTemp["GoodsTypeKey"].ToString().Trim();
                    string GoodsTypeKeyDefKey=dwTemp["GoodsTypeKeyDefKey"].ToString().Trim();
                    string GoodsKey=dwTemp["GoodsKey"].ToString().Trim();
           
            {
                if (SysID!=""&&KeyDefType!=""&&GoodsTypeKey!=""&&GoodsTypeKeyDefKey!=""&&GoodsKey!="")
                {
                    InstanceKey =SysID+"."+KeyDefType+"."+GoodsTypeKey+"."+GoodsTypeKeyDefKey+"."+GoodsKey;
                    dwTemp["InstanceKey"] = InstanceKey;
                    dwTemp.AcceptChanges();
                }
            }
            cmdSQL.Parameters.Add(new SqlParameter("@InstanceKey", dwRequest["InstanceKey"].ToString()));
            return base.BuildInstanceKey(cmdSQL, dwTemp);
        }
}
 public class GUIDesignTimeQueryCond : QueryCommand
    {
        public GUIDesignTimeQueryCond() : base() { }
        public GUIDesignTimeQueryCond(SqlCommand cmdSQL, DataTable dtRequest, string RequestJob)
         : base(cmdSQL, dtRequest,RequestJob) {  }

        public SqlCommand BuildCommand()
        {
            switch (RequestJob.Substring(6,4))
            {
                case "0000": break;
                case "1000": break;
                case "1001": break;
                case "1002": break;
                case "2000": 
                case "3000":
                    cmdSQL.Parameters.Add(new SqlParameter("@SysID", dwRequest["SysID"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@ProfileKey", dwRequest["ProfileKey"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@ProfileID", dwRequest["ProfileID"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@TableName", dwRequest["TableName"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@Column_Name", dwRequest["Column_Name"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@TableID", dwRequest["TableID"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@XPosition", dwRequest["XPosition"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@YPosition", dwRequest["YPosition"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@Height", dwRequest["Height"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@Width", dwRequest["Width"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@EditMode", dwRequest["EditMode"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@Lang_Code", dwRequest["Lang_Code"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@Column_Map_Name", dwRequest["Column_Map_Name"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@FrstUser", dwRequest["FrstUser"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@FrstDate", dwRequest["FrstDate"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@LastUser", dwRequest["LastUser"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@LastDate", dwRequest["LastDate"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@SubStatus", dwRequest["SubStatus"].ToString()));
cmdSQL.Parameters.Add(new SqlParameter("@Status", dwRequest["Status"].ToString()));
                
                    break;
                case "4000":
                    cmdSQL.Parameters.Add(new SqlParameter("@InstanceID", dwRequest["InstanceID"].ToString())); 
                    break;
            }
             return cmdSQL;

        }      

    }
 }
 
